import onerror from 'koa-onerror';

export default (app) => {
  onerror(app, {
    accepts() {
      return 'json';
    },
    json(err) {
      this.body = {
        code: err.status,
        message: err.message
      };
    }
  });
}
